<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 引入 vue.js 文件 -->
    <script src="../js/vue.js"></script>
</head>

<body>
    <div id="app">
        <!-- @click.stop  事件后面加.stop 阻止冒泡行为 -->
        <div @click="divBtn">
            aaaa
            <button @click.stop="btn">按钮</button>
        </div>

        <!-- @click.prevent  事件后面加.prevent 阻止冒泡行为 -->
        <form action="baidu">
            <input type="submit" value="提交" @click.prevent="submitClick">
        </form>

        <!-- @keyup  监听键盘的某个按键 enter键盘回车事件-->
        <input type="text" @keyup.enter="keyup">

        <!-- @click.once  事件后面加.once 执行一次点击 -->
        <button @click.once="btn1">按钮</button>


    </div>
    <script>
        new Vue({
            el: "#app",
            data: {
                message: "Hello Vue",
            },
            methods: {
                divBtn() {
                    alert("我是div");
                },
                btn() {
                    alert("我是按钮");
                },
                submitClick() {
                    alert("我是提交按钮");
                },
                keyup() {
                    console.log("我按了");
                },
                btn1() {
                    console.log("被点击了");
                }
            }
        });
    </script>
</body>

</html>